<template>
  <div>
    <bread-crumb :title="'添加分配短信'" @toggle="goBack"></bread-crumb>
    <card :msgNum="msgNum"></card>
    <!-- 表单 -->
    <el-form ref="form" :model="form" :rules="rules" label-width="80px">
      <el-form-item label="选择平台" prop="platform">
        <el-select v-model="form.platform" placeholder="选择平台">
          <el-option label="平台一" value="shanghai"></el-option>
          <el-option label="平台二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="短信条数" prop="num">
        <el-input
          v-model="form.num"
          placeholder="设置的短信条数，请勿超过短信总量"
          style="max-width:300px;"
        ></el-input>
      </el-form-item>
      <el-form-item label="短信签名" prop="sign">
        <el-select v-model="form.sign" placeholder="短信签名">
          <el-option label="短信签名一" value="shanghai"></el-option>
          <el-option label="短信签名二" value="beijing"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">确认提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import breadCrumb from './bread-crumb.vue'
import card from './card.vue'
export default {
  components: {
    breadCrumb,
    card
  },
  data() {
    return {
      msgNum: 199,
      form: {
        platform: '',
        num: '',
        sign: ''
      },
      rules: {
        platform: [{ required: true, message: '请选择平台', trigger: 'blur' }],
        num: [{ required: true, message: '请短信条数', trigger: 'blur' }],
        sign: [{ required: true, message: '请选择短信签名', trigger: 'change' }]
      }
    }
  },
  methods: {
    goBack() {
      this.$emit('toggle', 'add')
    },
    submit() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.$message.success('校验通过')
        } else {
          this.$message.error('校验未通过')
          return false
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.box-card {
  margin-bottom: 30px;
}
</style>
